from django.conf.urls import patterns, include, url
from django.conf import settings
from descrittori.views import trovapernome, distanza, descrizione, vicino_a, entro_raggio, aperto
from aggregatori.views import farmacie, scuolematerne, poste, supermarket
from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
from narratore.views import index, metacatalogo
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'TechWebDjango.views.home', name='home'),
    # url(r'^TechWebDjango/', include('TechWebDjango.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    (r'^xml/$', "converter.views.parsed_xml"),
    (r'^media/(?P<path>.*)$', 'django.views.static.serve',   
        {'document_root': settings.MEDIA_ROOT}),
    (r'^trovapernome/(?P<aggregatori>([A-Za-z^/]+/?[A-Za-z^/]*)*)/params/(?P<nome>([\sA-Za-z]+))', trovapernome),
    (r'^distanza/params/(?P<lat1>([a-zA-Z0-9.]+))/(?P<long1>([a-zA-Z0-9.]+))/(?P<lat2>([a-zA-Z0-9.]+))/(?P<long2>([a-zA-Z0-9.]+))', distanza),
    (r'^descrizione/(?P<aggr>([\dA-Za-z]+))/params/(?P<id>([A-Za-z0-9]+))', descrizione),
    (r'^vicino_a/(?P<aggregatori>([A-Za-z^/]+/?[A-Za-z^/]*)*)/params/(?P<lat1>[0-9.]+)/(?P<long1>[0-9.]+)/(?P<massimo>([0-9]+))', vicino_a),
    (r'^entro_raggio/(?P<aggregatori>([A-Za-z^/]+/?[A-Za-z^/]*)*)/params/(?P<lat1>[0-9.]+)/(?P<long1>[0-9.]+)/(?P<raggio>([0-9]+))', entro_raggio),
    (r'^aperto/params/(?P<lista>([\x20-x7E]+))/(?P<ora>([\x20-x7E]+))', aperto),
    (r'^farmacie/([\dA-Za-z]+)/([\dA-Za-z]+)/([.\d\sA-Za-z]+)', farmacie),
    (r'^farmacie', farmacie),
    (r'^supermarket/([\dA-Za-z]+)/([\dA-Za-z]+)/([.\d\sA-Za-z]+)', supermarket),
    (r'^supermarket', supermarket),
    (r'^poste/([\dA-Za-z]+)/([\dA-Za-z]+)/([.\d\sA-Za-z]+)', poste),
    (r'^poste', poste),
    (r'^scuolematerne/([\dA-Za-z]+)/([\dA-Za-z]+)/([.\d\sA-Za-z]+)', scuolematerne),
    (r'^scuolematerne', scuolematerne),
    (r'^$',index),
    (r'^catalogo',metacatalogo),
    #(r'^farmacie/', farmacie)
    (r'^css/(?P<path>.*)$', 'django.views.static.serve',{'document_root': "%s/%s" %(settings.MEDIA_ROOT,"css") }),
    (r'^immagini/(?P<path>.*)$', 'django.views.static.serve',{'document_root': "%s/%s" %(settings.MEDIA_ROOT,"immagini") }),
    (r'^script/(?P<path>.*)$', 'django.views.static.serve',{'document_root': "%s/%s" %(settings.MEDIA_ROOT,"script") }),

)


#
if settings.DEBUG:
    urlpatterns += patterns('django.contrib.staticfiles.views',
        url(r'^static/(?P<path>.*)$', 'serve'),
)
